package com.example.bottomnavigationdemo.ui.d_last

import android.os.Bundle
import android.util.Log
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import androidx.lifecycle.ViewModelProviders
import androidx.navigation.fragment.findNavController
import com.example.bottomnavigationdemo.R
import kotlinx.android.synthetic.main.last_fragment.*

class LastFragment : Fragment() {

    private lateinit var viewModel: LastViewModel

    override fun onCreateView(
        inflater: LayoutInflater, container: ViewGroup?,
        savedInstanceState: Bundle?
    ): View? {
        Log.e("-------->", "LastFragment-onCreate")
        return inflater.inflate(R.layout.last_fragment, container, false)
    }

    override fun onActivityCreated(savedInstanceState: Bundle?) {
        super.onActivityCreated(savedInstanceState)
        viewModel = ViewModelProviders.of(this).get(LastViewModel::class.java)
        button2.setOnClickListener {
            findNavController().navigate(R.id.action_navigation_last_to_navigation_home)
        }
        button.setOnClickListener {
            findNavController().navigate(R.id.action_navigation_last_to_blankFragment5)
        }

    }
    override fun onDestroy() {
        super.onDestroy()
        Log.e("-------->", "LastFragment-onDestroy")
    }
}